﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace SendReceive
{

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    unsafe public struct packet
    {
        public byte header0; //0
        public byte header1;//1
        public byte header2;//2
        public byte Packetcode;//3
        public UInt32 DeviceID;//4
        public UInt32 DriverID;//8
        //replace by currenttype
        public byte _hour;//14
        public byte _min;//13
        public byte _sec;//12
        public byte _day;//17
        public byte _month;//16
        public byte _year;//15
        //        public DateTime currentTime;
        //public float Latitude;//18//
        public byte Latitude0;
        public byte Latitude1;
        public byte Latitude2;
        public byte Latitude3;

        //public float Longitude;//22//
        public byte Longitude0;
        public byte Longitude1;
        public byte Longitude2;
        public byte Longitude3;

        public byte GPSSpeed;//26
        public UInt16 DigitalSignal;//27
        public UInt16 Fuellevel;//29
        public byte Mechanicspeed;//31
        public UInt32 Mechanicdistance;//32
        public UInt16 deleteDataCount; //so lan xoa du lieu trong ca//36
        public UInt16 UnhiredDistanc;// So km rong truoc cuoc khach//38
        public byte _hiredMin;//40
        public byte _hiredHour;//41
        public byte _hiredDay;//42
        public byte _hiredMonth;//43
        public byte _hiredYear;//44
//        public DateTime hiredTime;
        public byte hiredMoney0; //3 byte -100vnd//45
        public byte hiredMoney1; //3 byte -100vnd//46
        public byte hiredMoney2; //3 byte -100vnd//47

        public byte hiredDistance0;//3 byte - 10 m//48
        public byte hiredDistance1;//3 byte - 10 m//49
        public byte hiredDistance2;//3 byte - 10 m//50

        public UInt16 waiting;//second//51
        public byte _unhiredHour;//54
        public byte _unhiredMin;//53
        public byte _unhiredYear;//57
        public byte _unhiredMonth;//56
        public byte _unhiredDay;//55
//        public DateTime unhiredTime;
        public byte endPack0;//58
        public byte endPack1;//59
        public byte endPack2;//60
    }
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    unsafe public struct packetS
    {
        public byte header0;
        public byte header1;
        public byte header2;
        public byte Packetcode;
        public UInt32 DeviceID;
        public UInt32 DriverID;
        //replace by currenttype
        public byte _hour;
        public byte _min;
        public byte _sec;
        public byte _day;
        public byte _month;
        public byte _year;
        //        public DateTime currentTime;
        //public float Latitude;//18//
        public byte Latitude0;
        public byte Latitude1;
        public byte Latitude2;
        public byte Latitude3;

        //public float Longitude;//22//
        public byte Longitude0;
        public byte Longitude1;
        public byte Longitude2;
        public byte Longitude3;

        public byte GPSSpeed;
        public UInt16 DigitalSignal;
        public UInt16 Fuellevel;
        public byte Mechanicspeed;
        public UInt32 Mechanicdistance;
        public UInt16 deleteDataCount; //so lan xoa du lieu trong ca
        public UInt16 UnhiredDistanc;// So km rong truoc cuoc khach
        public byte _hiredMin;
        public byte _hiredHour;
        public byte _hiredDay;
        public byte _hiredMonth;
        public byte _hiredYear;
        //        public DateTime hiredTime;
        public byte hiredMoney0; //3 byte -100vnd
        public byte hiredMoney1; //3 byte -100vnd
        public byte hiredMoney2; //3 byte -100vnd

        public byte hiredDistance0;//3 byte - 10 m
        public byte hiredDistance1;//3 byte - 10 m
        public byte hiredDistance2;//3 byte - 10 m

        public UInt16 waiting;//second
        //        public DateTime unhiredTime;
        public byte endPack0;
        public byte endPack1;
        public byte endPack2;
    }
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    unsafe public struct packetSS
    {
        public byte header0;
        public byte header1;
        public byte header2;
        public byte Packetcode;
        public UInt32 DeviceID;
        public UInt32 DriverID;
        //replace by currenttype
        public byte _hour;
        public byte _min;
        public byte _sec;
        public byte _day;
        public byte _month;
        public byte _year;
        //        public DateTime currentTime;
        //public float Latitude;//18//
        public byte Latitude0;
        public byte Latitude1;
        public byte Latitude2;
        public byte Latitude3;

        //public float Longitude;//22//
        public byte Longitude0;
        public byte Longitude1;
        public byte Longitude2;
        public byte Longitude3;

        public byte GPSSpeed;
        public UInt16 DigitalSignal;
        public UInt16 Fuellevel;
        public byte Mechanicspeed;
        public UInt32 Mechanicdistance;
        public UInt16 deleteDataCount; //so lan xoa du lieu trong ca
        public UInt16 UnhiredDistanc;// So km rong truoc cuoc khach
        public byte endPack0;
        public byte endPack1;
        public byte endPack2;
    }
    public struct processedPacket
    {
           public string  code;
           public string  codeview;
           public string  name;
           public string  note;
           public string  edituser;
           public DateTime  edittime;
           public Int16 lock_;
           public DateTime lockdate;
           public string companycode;
           public int deviceid;
           public int driverid;
           public DateTime reporttime;
           public float latitude;
           public float longitude;
           public float gpsspeed;
           public float fuellevel;
           public float mechanicspeed;
           public float mechanicdistance;
           public int datadelete;
           public float wastedistance;
           public DateTime pickuptime;
           public decimal fare;
           public float faredistance;
           public int waitingtime;
           public DateTime endfare;
           public int positionfix;
           public int SOS;
           public int openengine;
           public int opendoor;
           public int openair;
           public int fuelrelay;
           public int camerarelay;
           public int incar;
           public int infare;
           public int infarecamere;
           public int engineon;
           public int checker;
           public int waitingfare;
           public int endfareevent;
           public int memory;
           public int replay;
    };
}
